<script lang="ts" setup>
import { ref } from 'vue'

const todayStats = ref({
  visits: 233,
  users: 233,
  purchases: 233,
})

const tableData = ref({
  total: {
    visits: 233,
    purchases: 233,
    listeners: 23,
    institutions: 233,
  },
  yesterday: {
    visits: 234,
    purchases: 234,
    listeners: 32,
    institutions: 323,
  },
})
</script>

<template>
  <div class="home">
    <!-- 数据概览卡片 -->
    <el-row :gutter="20" class="stats-cards">
      <el-col :span="8">
        <el-card class="stat-card">
          <div class="icon-wrapper blue">
            <el-icon><Message /></el-icon>
          </div>
          <div class="stat-info">
            <div class="number">{{ todayStats.visits }}</div>
            <div class="label">今日访问量</div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="8">
        <el-card class="stat-card">
          <div class="icon-wrapper pink">
            <el-icon><User /></el-icon>
          </div>
          <div class="stat-info">
            <div class="number">{{ todayStats.users }}</div>
            <div class="label">新增用户量</div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="8">
        <el-card class="stat-card">
          <div class="icon-wrapper green">
            <el-icon><ShoppingCart /></el-icon>
          </div>
          <div class="stat-info">
            <div class="number">{{ todayStats.purchases }}</div>
            <div class="label">今日购买量</div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <!-- 统计表格 -->
    <el-card class="stats-table">
      <el-table :data="[tableData.total, tableData.yesterday]" style="width: 100%">
        <el-table-column prop="type" label="" width="100">
          <template #default="{ $index }">
            {{ $index === 0 ? '总量' : '昨日' }}
          </template>
        </el-table-column>
        <el-table-column prop="visits" label="课程访问量" />
        <el-table-column prop="purchases" label="课程购买量" />
        <el-table-column prop="listeners" label="听课人数" />
        <el-table-column prop="institutions" label="机构数" />
      </el-table>
    </el-card>

    <!-- 图表区域将在这里添加 -->
  </div>
</template>

<style scoped lang="less">
.home {
  padding: 20px;
  background: #f5f5f5;

  .stats-cards {
    margin-bottom: 20px;

    .stat-card {
      display: flex;
      align-items: center;
      padding: 20px;

      .icon-wrapper {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 20px;

        &.blue {
          background-color: #409eff;
        }
        &.pink {
          background-color: #f56c6c;
        }
        &.green {
          background-color: #67c23a;
        }

        .el-icon {
          font-size: 24px;
          color: white;
        }
      }

      .stat-info {
        .number {
          font-size: 24px;
          font-weight: bold;
          margin-bottom: 8px;
        }
        .label {
          color: #666;
        }
      }
    }
  }

  .stats-table {
    margin-bottom: 20px;
  }
}
</style>
